home *** CD-ROM | disk | FTP | other *** search
- package javax.help;
-
- import com.sun.java.help.impl.XmlReader;
- import java.beans.PropertyChangeSupport;
- import java.io.Reader;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import java.util.Locale;
- import java.util.Vector;
- import javax.help.Map.ID;
- import javax.help.event.EventListenerList;
- import javax.help.event.HelpSetEvent;
- import javax.help.event.HelpSetListener;
-
- public class HelpSet {
- private static String errorMsg = null;
- protected EventListenerList listenerList;
- public static final String publicIDString = "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN";
- public static final Object implRegistry = new StringBuffer("HelpSet.implRegistry");
- public static final String helpBrokerClass = "helpBroker/class";
- public static final String helpBrokerLoader = "helpBroker/loader";
- public static final Object kitTypeRegistry = new StringBuffer("JHelpViewer.kitTypeRegistry");
- public static final Object kitLoaderRegistry = new StringBuffer("JHelpViewer.kitLoaderRegistry");
- private String title;
- private Map map;
- private TryMap combinedMap;
- private URL helpset;
- private String homeID;
- private Locale locale;
- private ClassLoader loader;
- private Vector views;
- private Vector helpsets;
- private static HelpBroker defaultHelpBroker;
- private Vector subHelpSets;
- private static Hashtable defaultKeys;
- private Hashtable localKeys;
- private PropertyChangeSupport changes;
- private static final boolean debug = false;
- // $FF: synthetic field
- static Class class$javax$help$event$HelpSetListener;
- // $FF: synthetic field
- static Class class$javax$help$HelpSet;
-
- public HelpSet(ClassLoader var1) {
- this.listenerList = new EventListenerList();
- this.locale = Locale.getDefault();
- this.views = new Vector();
- this.subHelpSets = new Vector();
- this.localKeys = new Hashtable();
- this.changes = new PropertyChangeSupport(this);
- this.helpsets = new Vector();
- this.loader = var1;
- }
-
- public HelpSet() {
- this.listenerList = new EventListenerList();
- this.locale = Locale.getDefault();
- this.views = new Vector();
- this.subHelpSets = new Vector();
- this.localKeys = new Hashtable();
- this.changes = new PropertyChangeSupport(this);
- this.helpsets = new Vector();
- this.loader = null;
- }
-
- public HelpSet(ClassLoader var1, URL var2) throws HelpSetException {
- this(var1);
- this.helpset = var2;
- DefaultHelpSetFactory var3 = new DefaultHelpSetFactory();
- this.parseInto(var2, var3);
- HelpSet var4 = var3.parsingEnded(this);
- if (var4 == null) {
- throw new HelpSetException("Could not parse\n" + errorMsg);
- }
- }
-
- public static URL findHelpSet(ClassLoader var0, String var1, String var2, Locale var3) {
- return HelpUtilities.getLocalizedResource(var0, var1, var2, var3, true);
- }
-
- public static URL findHelpSet(ClassLoader var0, String var1, Locale var2) {
- String var3;
- String var4;
- if (var1.endsWith(".hs")) {
- var3 = var1.substring(0, var1.length() - 3);
- var4 = ".hs";
- } else {
- var3 = var1;
- var4 = ".hs";
- }
-
- return findHelpSet(var0, var3, var4, var2);
- }
-
- public static URL findHelpSet(ClassLoader var0, String var1) {
- return findHelpSet(var0, var1, Locale.getDefault());
- }
-
- public HelpBroker createHelpBroker() {
- Object var1 = null;
- String var2 = (String)this.getKeyData(implRegistry, "helpBroker/class");
- ClassLoader var3 = (ClassLoader)this.getKeyData(implRegistry, "helpBroker/loader");
- if (var3 == null) {
- var3 = this.getLoader();
- }
-
- try {
- Class var4;
- if (var3 != null) {
- var4 = var3.loadClass(var2);
- } else {
- var4 = Class.forName(var2);
- }
-
- var6 = (HelpBroker)var4.newInstance();
- } catch (Throwable var5) {
- var6 = null;
- }
-
- if (var6 != null) {
- var6.setHelpSet(this);
- }
-
- return var6;
- }
-
- public void add(HelpSet var1) {
- debug("add(" + var1 + ")");
- this.helpsets.addElement(var1);
- this.fireHelpSetAdded(this, var1);
- this.combinedMap = null;
- }
-
- public boolean remove(HelpSet var1) {
- if (this.helpsets.removeElement(var1)) {
- this.fireHelpSetRemoved(this, var1);
- this.combinedMap = null;
- return true;
- } else {
- return false;
- }
- }
-
- public Enumeration getHelpSets() {
- return this.helpsets.elements();
- }
-
- public boolean contains(HelpSet var1) {
- if (var1 == this) {
- return true;
- } else {
- Enumeration var2 = this.helpsets.elements();
-
- while(var2.hasMoreElements()) {
- HelpSet var3 = (HelpSet)var2.nextElement();
- if (var3.contains(var1)) {
- return true;
- }
- }
-
- return false;
- }
- }
-
- public void addHelpSetListener(HelpSetListener var1) {
- debug("addHelpSetListener(" + var1 + ")");
- this.listenerList.add(class$javax$help$event$HelpSetListener == null ? (class$javax$help$event$HelpSetListener = class$("javax.help.event.HelpSetListener")) : class$javax$help$event$HelpSetListener, var1);
- }
-
- public void removeHelpSetListener(HelpSetListener var1) {
- this.listenerList.remove(class$javax$help$event$HelpSetListener == null ? (class$javax$help$event$HelpSetListener = class$("javax.help.event.HelpSetListener")) : class$javax$help$event$HelpSetListener, var1);
- }
-
- protected void fireHelpSetAdded(Object var1, HelpSet var2) {
- Object[] var3 = this.listenerList.getListenerList();
- HelpSetEvent var4 = null;
-
- for(int var5 = var3.length - 2; var5 >= 0; var5 -= 2) {
- if (var3[var5] == (class$javax$help$event$HelpSetListener == null ? (class$javax$help$event$HelpSetListener = class$("javax.help.event.HelpSetListener")) : class$javax$help$event$HelpSetListener)) {
- if (var4 == null) {
- var4 = new HelpSetEvent(this, var2, 0);
- }
-
- ((HelpSetListener)var3[var5 + 1]).helpSetAdded(var4);
- }
- }
-
- }
-
- protected void fireHelpSetRemoved(Object var1, HelpSet var2) {
- Object[] var3 = this.listenerList.getListenerList();
- HelpSetEvent var4 = null;
-
- for(int var5 = var3.length - 2; var5 >= 0; var5 -= 2) {
- if (var3[var5] == (class$javax$help$event$HelpSetListener == null ? (class$javax$help$event$HelpSetListener = class$("javax.help.event.HelpSetListener")) : class$javax$help$event$HelpSetListener)) {
- if (var4 == null) {
- var4 = new HelpSetEvent(this, var2, 1);
- }
-
- ((HelpSetListener)var3[var5 + 1]).helpSetRemoved(var4);
- }
- }
-
- }
-
- public String getTitle() {
- return this.title == null ? "" : this.title;
- }
-
- public void setTitle(String var1) {
- String var2 = this.title;
- this.title = var1;
- this.changes.firePropertyChange("title", var2, var1);
- }
-
- public Locale getLocale() {
- return this.locale;
- }
-
- private void setLocale(Locale var1) {
- Locale var2 = this.locale;
- this.locale = var1;
- this.changes.firePropertyChange("locale", var2, this.locale);
- }
-
- public Map.ID getHomeID() {
- if (this.homeID == null) {
- return null;
- } else {
- try {
- return ID.create(this.homeID, this);
- } catch (Exception var2) {
- return null;
- }
- }
- }
-
- public void setHomeID(String var1) {
- this.homeID = var1;
- this.changes.firePropertyChange("homeID", var1, var1);
- }
-
- public Map getCombinedMap() {
- if (this.combinedMap == null) {
- this.combinedMap = new TryMap();
- if (this.map != null) {
- this.combinedMap.add(this.map);
- }
-
- Enumeration var1 = this.helpsets.elements();
-
- while(var1.hasMoreElements()) {
- HelpSet var2 = (HelpSet)var1.nextElement();
- this.combinedMap.add(var2.getLocalMap());
- }
- }
-
- return this.combinedMap;
- }
-
- public Map getLocalMap() {
- return this.map;
- }
-
- public void setLocalMap(Map var1) {
- this.map = var1;
- }
-
- public URL getHelpSetURL() {
- return this.helpset;
- }
-
- public ClassLoader getLoader() {
- return this.loader;
- }
-
- public NavigatorView[] getNavigatorViews() {
- NavigatorView[] var1 = new NavigatorView[this.views.size()];
- this.views.copyInto(var1);
- return var1;
- }
-
- public NavigatorView getNavigatorView(String var1) {
- debug("getNavigatorView(" + var1 + ")");
-
- for(int var2 = 0; var2 < this.views.size(); ++var2) {
- NavigatorView var3 = (NavigatorView)this.views.elementAt(var2);
- if (var3.getName().equals(var1)) {
- debug(" = " + var3);
- return var3;
- }
- }
-
- debug(" = null");
- return null;
- }
-
- public String toString() {
- return this.getTitle();
- }
-
- public static HelpSet parse(URL var0, ClassLoader var1, HelpSetFactory var2) {
- HelpSet var3 = new HelpSet(var1);
- var3.helpset = var0;
- var3.parseInto(var0, var2);
- return var2.parsingEnded(var3);
- }
-
- public void parseInto(URL var1, HelpSetFactory var2) {
- try {
- URLConnection var4 = var1.openConnection();
- Reader var3 = XmlReader.createReader(var4);
- var2.parsingStarted(var1);
- (new HelpSetParser(var2)).parseInto(var3, this);
- var3.close();
- } catch (Exception var6) {
- var2.reportMessage("Got an IOException (" + var6.getMessage() + ")", false);
- }
-
- for(int var7 = 0; var7 < this.subHelpSets.size(); ++var7) {
- HelpSet var5 = (HelpSet)this.subHelpSets.elementAt(var7);
- this.add(var5);
- }
-
- }
-
- protected void addView(NavigatorView var1) {
- this.views.addElement(var1);
- }
-
- protected void addSubHelpSet(HelpSet var1) {
- this.subHelpSets.addElement(var1);
- }
-
- public Object getKeyData(Object var1, String var2) {
- Object var3 = null;
- Hashtable var4 = (Hashtable)this.localKeys.get(var1);
- if (var4 != null) {
- var3 = var4.get(var2);
- }
-
- if (var3 == null) {
- var4 = (Hashtable)defaultKeys.get(var1);
- if (var4 != null) {
- var3 = var4.get(var2);
- }
- }
-
- return var3;
- }
-
- public void setKeyData(Object var1, String var2, Object var3) {
- Hashtable var4 = (Hashtable)this.localKeys.get(var1);
- if (var4 == null) {
- var4 = new Hashtable();
- this.localKeys.put(var1, var4);
- }
-
- var4.put(var2, var3);
- }
-
- private static void setDefaultKeyData(Object var0, String var1, Object var2) {
- if (defaultKeys == null) {
- defaultKeys = new Hashtable();
- }
-
- Hashtable var3 = (Hashtable)defaultKeys.get(var0);
- if (var3 == null) {
- var3 = new Hashtable();
- defaultKeys.put(var0, var3);
- }
-
- var3.put(var1, var2);
- }
-
- private static void debug(String var0) {
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(var2.getMessage());
- }
- }
-
- // $FF: synthetic method
- static void access$000(String var0) {
- debug(var0);
- }
-
- // $FF: synthetic method
- static String access$100() {
- return errorMsg;
- }
-
- // $FF: synthetic method
- static String access$102(String var0) {
- errorMsg = var0;
- return var0;
- }
-
- // $FF: synthetic method
- static void access$200(HelpSet var0, Locale var1) {
- var0.setLocale(var1);
- }
-
- static {
- setDefaultKeyData(implRegistry, "helpBroker/class", "javax.help.DefaultHelpBroker");
- setDefaultKeyData(kitTypeRegistry, "text/html", "com.sun.java.help.impl.CustomKit");
- ClassLoader var0 = (class$javax$help$HelpSet == null ? (class$javax$help$HelpSet = class$("javax.help.HelpSet")) : class$javax$help$HelpSet).getClassLoader();
- if (var0 != null) {
- setDefaultKeyData(implRegistry, "helpBroker/loader", var0);
- setDefaultKeyData(kitLoaderRegistry, "text/html", var0);
- }
-
- defaultHelpBroker = null;
- }
- }
-